Micron Document
`:top
`!Pyrex`! is a `F33f`_`[programming language`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Programming_language]`_`f for creating `F33f`_`[Python`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Python_(programming_language)]`_`f `F33f`_`[modules`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Module_(programming)]`_`f. Its syntax is very close to Python and it makes it easy for Python programmers to write non-Python supporting code for interfacing modules in a language which is as close to Python as possible.

Python itself only provides a `F33f`_`[C`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=C_(programming_language)]`_`f `F33f`_`[API`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Application_programming_interface]`_`f to write extension modules, which allows writing of `F33f`_`[functions`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Subroutine]`_`f and `F33f`_`[datatypes`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Datatype]`_`f in C. These can then be accessed from Python. It is possible to wrap the functions and datatypes of existing C `F33f`_`[libraries`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Library_(computer_science)]`_`f as Python objects and therefore make them available to Python.`:cite-ref-2[`F5bf`_`[2`#cite-note-2]`_`f]

Pyrex allows the user to write extension modules in a Python-like language which may directly access the external C code. The similarity of Pyrex's syntax to Python's makes it easy to write Python modules, but there are some functional limitations.`:cite-ref-3[`F5bf`_`[3`#cite-note-3]`_`f] The programmer must specify the name of C-header files, `F33f`_`[enumerations`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Enumerated_type]`_`f, datatypes and functions needing to be accessed in the module, then they can be used as if they were Python objects. The Pyrex compiler will generate the necessary glue code automatically and compile the Pyrex code into a working Python module.

There are tools like `F33f`_`[SWIG`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=SWIG]`_`f or Python's foreign function library `*ctypes`* which can be used for this task without requiring much additional code, but this is limited to making an external library available in Python code.`:cite-ref-4[`F5bf`_`[4`#cite-note-4]`_`f]`:cite-ref-5[`F5bf`_`[5`#cite-note-5]`_`f] If adjustments to the API are needed, glue code must again be written manually.

>>Contents

• `F0af`_`[See also`#see-also]`_`f
• `F0af`_`[References`#references]`_`f
• `F0af`_`[External links`#external-links]`_`f

-─

>>See also

• `F33f`_`[Cython`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Cython]`_`f

>>References

`:cite-note-pyrex-ann-1`!1.`! `:citerefgreg-at-cosc2002`agreg at cosc (3 April 2002). "ANN: Pyrex — a language for writing Python extension modules". Retrieved 24 February 2014.
`:cite-note-2`!2.`! `F0af`_`[↑`#cite-ref-2]`_`f `:citerefmark-lutz2006`aMark Lutz (2006). `*Programming Python`*. `F33f`_`[O'Reilly Media`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=O'Reilly_Media]`_`f. p. 1461. `F33f`_`[ISBN`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=ISBN_(identifier)]`_`f 9780596554613.
`:cite-note-3`!3.`! `F0af`_`[↑`#cite-ref-3]`_`f `:citerefalex-martelli2009`aAlex Martelli (2009). `*Python in a Nutshell`*. `F33f`_`[O'Reilly Media`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=O'Reilly_Media]`_`f. p. 650. `F33f`_`[ISBN`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=ISBN_(identifier)]`_`f 9781449379100.
`:cite-note-4`!4.`! `F0af`_`[↑`#cite-ref-4]`_`f `:citerefjang-hyuk-kwonthom-dunningkum-won-choaurore-savoy-navarro2010`aJang Hyuk Kwon; Thom Dunning; Kum Won Cho; Aurore Savoy-Navarro (2010). `*Future Application and Middleware Technology on E-Science`*. `F33f`_`[Springer US`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Springer_(publisher)]`_`f. p. 141. `F33f`_`[ISBN`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=ISBN_(identifier)]`_`f 9781441917195.
`:cite-note-5`!5.`! `F0af`_`[↑`#cite-ref-5]`_`f `:citerefwesley-chun2012`aWesley Chun (2012). `*Core Python Applications Programming`*. `F33f`_`[Prentice Hall`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=Prentice_Hall]`_`f. p. 385. `F33f`_`[ISBN`:/page/wikibook/entry.mu`zim=wikipedia_en_all_nopic_2025-08.zim|entry_path=ISBN_(identifier)]`_`f 9780132678209.

>>External links

• Official website

`c`F0af`_`[↑ Back to top`#top]`_`f`a